<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="cyys" uri="http://www.cyys.com/cyystaglib"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit">
  	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<title>${SYSTEM_NAME}</title>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/layui/css/layui.css?v=${FILE_VERSION}" media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/style/admin.css?v=${FILE_VERSION}" media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/fileUpload.css?v=${FILE_VERSION}">
</head>
<body>
<div class="layui-fluid">
	<div class="layui-card">
		<div class="layui-card-body" style="padding: 15px;">
		<form class="layui-form" method="post" id="basicform" >
			<input id="id" name="id" value="${version.id }" type="hidden">

			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label layui-form-required">版本类型</label>
				<div class="layui-input-inline">
					<select name="type">
						<c:forEach items="${typeMap}" var="t">
							<option value="${t.key }" <c:if test="${t.key eq version.type}">selected="selected"</c:if>>${t.value }</option>
						</c:forEach>
					</select>
				</div>
			</div>
			
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label layui-form-required">版本号</label>
				<div class="layui-input-block">
					<input name="version" placeholder="请输入版本号"
						class="layui-input" lay-verify="required" value="${version.version }" maxlength="10">
				</div>
			</div>
			
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label layui-form-required">更新内容</label>
				<div class="layui-input-block">
					<textarea name="content" lay-verify="required" placeholder="请输入更新内容,最大不能超过1000字"
						class="layui-textarea" maxlength="1000">${version.content }</textarea>
				</div>
			</div>
			
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label layui-form-required">更新时间</label>
				<div class="layui-input-inline">
					<input type="text" id="dateUpdate" name="dateUpdate" 
						value="<fmt:formatDate value="${version.dateUpdate }" pattern="yyyy-MM-dd"/>" lay-verify="required"
						class="layui-input" readonly="readonly">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">附件</label>
				<div class="layui-input-block">
					<button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="$selectFileManage(2,'attachments')">选择附件</button>
					<blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;" >
						预览图<font style="color: red">(可拖拽图标进行排序,排序后请点击提交按钮)</font>：
						<ul class="layui-upload-ul" id="attachments">
							<c:if test="${not empty version.attachments}">
								<c:forEach items='${fn:split(version.attachments,",")}' var="item" >
									<li class="layui-upload-list" style="width:100px;">
										<input value="${item}" type="hidden" class="fileUrlInput">
										<c:set var="fileExt" value="${fn:substring(item,cyys:lastIndexOf(item, '.') + 1,item.length())}" />
										<img class="layui-upload-img" src="${FILE_WEB_PATH}${item}" onerror="this.src=getSrcByExt('${item}')">
										<div class="closeBtu" onclick="deleteFile('${item}',this,true)">
											<img src="/static/images/xbtn.png">
										</div>
									</li>
								</c:forEach>
							</c:if>
						</ul>
						<div style="clear:both;"></div>
					</blockquote>
					<input class="fileUrlsInput" value="${version.attachments}" name="attachments" type="hidden">
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn layui-btn-primary layui-border-blue" lay-submit="" lay-filter="sub">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary layui-border-blue">重置</button>
					<button type="button" class="layui-btn layui-btn-primary layui-border-red" onclick="closed()">关闭</button>
				</div>
			</div>
		</form>
	</div>
	</div>
</div>
	<script src="${pageContext.request.contextPath}/static/js/common-2.0.0.js?v=${FILE_VERSION}"></script>
	<script src="${pageContext.request.contextPath}/static/layuiadmin/layui/layui.js?v=${FILE_VERSION}"></script>
	<script src="${pageContext.request.contextPath}/static/js/jquery-3.3.1.min.js?v=${FILE_VERSION}"></script>
	<script src="${pageContext.request.contextPath}/static/js/common/coreInput-2.0.0.js?v=${FILE_VERSION}"></script>
	<!-- 图片上传 -->
	<script src="${pageContext.request.contextPath}/static/js/upload/fileUpload-2.0.0.js?v=${FILE_VERSION}"></script>

	<script>
		layui.use(['form', 'laydate'], function() {
			var form = layui.form;
			var laydate = layui.laydate;
			
			//日期选择器
			laydate.render({ 
			  elem: '#dateUpdate'
				,trigger: 'click'
			});
			
			form.on('submit(sub)', function(data){
				var attachments= getMutifileUrl('#attachments');
				if(attachments==null){
					attachments= "";
				}
				data.field['attachments']= attachments;
				return saveOrUpdate($("#id").val(),"/sys/version",data);
			});
		});
		
	</script>
</body>
</html>